home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / VideoFolder 1.0a / Source / MoreFiles 1.4.1 / FSpCompat.p < prev    next >
Text File  |  1995-12-21  |  10KB  |  261 lines

  1. UNIT FSpCompat;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    FSSpec compatibility functions                                            }
  6. {                                                                            }
  7. {    by Jim Luther, Apple Developer Technical Support Emeritus                }
  8. {                                                                            }
  9. {    File:        FSpCompat.p                                                    }
  10. {                                                                            }
  11. {    Copyright © 1992-1995 Apple Computer, Inc.                                }
  12. {    All rights reserved.                                                    }
  13. {                                                                            }
  14. {    You may incorporate this sample code into your applications without        }
  15. {    restriction, though the sample code has been provided "AS IS" and the    }
  16. {    responsibility for its operation is 100% yours.  However, what you are    }
  17. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  18. {    after having made changes. If you're going to re-distribute the source,    }
  19. {    we require that you make it clear in the source that the code was        }
  20. {    descended from Apple Sample Code, but that you've made changes.            }
  21.  
  22.  
  23. INTERFACE
  24.  
  25. USES
  26.     Files;
  27.  
  28. {***************************************************************************}
  29.  
  30.  
  31.     FUNCTION FSMakeFSSpecCompat (vRefNum: INTEGER;
  32.                                     dirID: LONGINT;
  33.                                     fileName: Str255;
  34.                                     VAR spec: FSSpec): OSErr;
  35. {    The FSMakeFSSpecCompat function fills in the fields of an FSSpec        }
  36. {    record. If the file system can't create the FSSpec, then the            }
  37. {    compatibility code creates a FSSpec that is exactly like an FSSpec        }
  38. {    except that spec.name for a file may not have the same capitalization    }
  39. {    as the file's catalog entry on the disk volume. That is because            }
  40. {    fileName is parsed to get the name instead of getting the name back        }
  41. {    from the file system. This works fine with System 6 where FSMakeSpec    }
  42. {    isn't available.                                                        }
  43. {                                                                            }
  44. {    vRefNum        input:    Volume specification.                                }
  45. {    dirID        input:    Directory ID.                                        }
  46. {    fileName    input:    Pointer to object name, or nil when dirID specifies    }
  47. {                        a directory that's the object.                        }
  48. {    spec        output:    A file system specification to be filled in by        }
  49. {                        FSMakeFSSpecCompat.                                    }
  50.  
  51.  
  52. {***************************************************************************}
  53.  
  54.  
  55.     FUNCTION FSpOpenDFCompat ({CONST}VAR spec: FSSpec;
  56.                                     permission: SignedByte;
  57.                                     VAR refNum: INTEGER): OSErr;
  58. {    The FSpOpenDFCompat function opens the data fork of the file specified    }
  59. {    by spec.                                                                }
  60. {    Differences from FSpOpenDF: If FSpOpenDF isn't available,                }
  61. {    FSpOpenDFCompat uses PHBOpen because System 6 doesn't support            }
  62. {    PBHOpenDF. This means FSpOpenDFCompat could accidentally open a driver    }
  63. {    if the spec->name begins with a period.                                    }
  64. {                                                                            }
  65. {    spec        input:    An FSSpec record specifying the file whose data        }
  66. {                        fork is to be opened.                                }
  67. {    permission    input:    A constant indicating the desired file access        }
  68. {                        permissions.                                        }
  69. {    refNum        output:    A reference number of an access path to the file's    }
  70. {                        data fork.                                            }
  71.  
  72.  
  73. {***************************************************************************}
  74.  
  75.  
  76.     FUNCTION FSpOpenRFCompat ({CONST}VAR spec: FSSpec;
  77.                                     permission: SignedByte;
  78.                                     VAR refNum: INTEGER): OSErr;
  79. {    The FSpOpenRFCompat function opens the resource fork of the file        }
  80. {    specified by spec.                                                        }
  81. {                                                                            }
  82. {    spec        input:    An FSSpec record specifying the file whose resource    }
  83. {                        fork is to be opened.                                }
  84. {    permission    input:    A constant indicating the desired file access        }
  85. {                        permissions.                                        }
  86. {    refNum        output:    A reference number of an access path to the file's    }
  87. {                        resource fork.                                        }
  88.  
  89.  
  90. {***************************************************************************}
  91.  
  92.  
  93.     FUNCTION FSpCreateCompat ({CONST}VAR spec: FSSpec;
  94.                                     creator: OSType;
  95.                                     fileType: OSType;
  96.                                     scriptTag: ScriptCode): OSErr;
  97. {    The FSpCreateCompat function creates a new file with the specified        }
  98. {    type, creator, and script code.                                            }
  99. {    Differences from FSpCreate: FSpCreateCompat correctly sets the            }
  100. {    fdScript in the file's FXInfo record to scriptTag if the problem        }
  101. {    isn't fixed in the File Manager code.                                    }
  102. {                                                                            }
  103. {    spec        input:    An FSSpec record specifying the file to create.        }
  104. {    creator        input:    The creator of the new file.                        }
  105. {    fileType    input    The file type of the new file.                        }
  106. {    scriptCode    input:    The code of the script system in which the file        }
  107. {                        name is to be displayed.                            }
  108.  
  109.  
  110. {***************************************************************************}
  111.  
  112.  
  113.     FUNCTION FSpDirCreateCompat ({CONST}VAR spec: FSSpec;
  114.                                     scriptTag: ScriptCode;
  115.                                     VAR createdDirID: LONGINT): OSErr;
  116. {    The FSpDirCreateCompat function creates a new directory and returns        }
  117. {    the directory ID of the newDirectory.                                    }
  118. {                                                                            }
  119. {    spec            input:    An FSSpec record specifying the directory to    }
  120. {                            create.                                            }
  121. {    scriptCode        input:    The code of the script system in which the        }
  122. {                            directory name is to be displayed.                }
  123. {    createdDirID    output:    The directory ID of the directory that was        }
  124. {                            created.                                        }
  125.  
  126.  
  127. {***************************************************************************}
  128.  
  129.  
  130.     FUNCTION FSpDeleteCompat ({CONST}VAR spec: FSSpec): OSErr;
  131. {    The FSpDeleteCompat function deletes a file or directory.                }
  132. {                                                                            }
  133. {    spec            input:    An FSSpec record specifying the file or         }
  134. {                            directory to delete.                            }
  135.  
  136.  
  137. {***************************************************************************}
  138.  
  139.  
  140.     FUNCTION FSpGetFInfoCompat ({CONST}VAR spec: FSSpec;
  141.                                     VAR fndrInfo: FInfo): OSErr;
  142. {    The FSpGetFInfoCompat function gets the finder information for a file.    }
  143. {                                                                            }
  144. {    spec        input:    An FSSpec record specifying the file.                }
  145. {    fndrInfo    output:    If the object is a file, then its FInfo.            }
  146.  
  147.  
  148. {***************************************************************************}
  149.  
  150.  
  151.     FUNCTION FSpSetFInfoCompat ({CONST}VAR spec: FSSpec;
  152.                                     fndrInfo: FInfo): OSErr;
  153. {    The FSpSetFInfoCompat function sets the finder information for a file.    }
  154. {                                                                            }
  155. {    spec        input:    An FSSpec record specifying the file.                }
  156. {    fndrInfo    input:    The FInfo.                                            }
  157.  
  158.  
  159. {***************************************************************************}
  160.  
  161.  
  162.     FUNCTION FSpSetFLockCompat ({CONST}VAR spec: FSSpec): OSErr;
  163. {    The FSpSetFLockCompat function locks a file.                            }
  164. {                                                                            }
  165. {    spec        input:    An FSSpec record specifying the file.                }
  166.  
  167.  
  168. {***************************************************************************}
  169.  
  170.  
  171.     FUNCTION FSpRstFLockCompat ({CONST}VAR spec: FSSpec): OSErr;
  172. {    The FSpRstFLockCompat function unlocks a file.                            }
  173. {                                                                            }
  174. {    spec        input:    An FSSpec record specifying the file.                }
  175.  
  176.  
  177. {***************************************************************************}
  178.  
  179.  
  180.     FUNCTION FSpRenameCompat ({CONST}VAR spec: FSSpec;
  181.                                     newName: Str255): OSErr;
  182. {    The FSpRenameCompat function renames a file or directory.                }
  183. {                                                                            }
  184. {    spec        input:    An FSSpec record specifying the file.                }
  185. {    newName        input:    The new name of the file or directory.                }
  186.  
  187.  
  188. {***************************************************************************}
  189.  
  190.  
  191.     FUNCTION FSpCatMoveCompat ({CONST}VAR source: FSSpec;
  192.                                     {CONST}VAR dest: FSSpec): OSErr;
  193. {    The FSpCatMoveCompat function moves a file or directory to a different    }
  194. {    location on on the same volume.                                            }
  195. {                                                                            }
  196. {    source        input:    An FSSpec record specifying the file or directory.    }
  197. {    dest        input:    An FSSpec record specifying the name and location    }
  198. {                        of the directory into which the source file or        }
  199. {                        directory is to be moved.                            }
  200.  
  201.  
  202. {***************************************************************************}
  203.  
  204.  
  205.     FUNCTION FSpExchangeFilesCompat ({CONST}VAR source: FSSpec;
  206.                                     {CONST}VAR dest: FSSpec): OSErr;
  207. {    The FSpExchangeFilesCompat function swaps the data in two files by        }
  208. {    changing the information in the volume's catalog and, if the files        }
  209. {    are open, in the file control blocks.                                    }
  210. {    Differences from FSpExchangeFiles: Correctly exchanges files on volumes    }
  211. {    that don't support PBExchangeFiles. FSpExchangeFiles attempts to        }
  212. {    support volumes that don't support PBExchangeFiles, but in System 7,    }
  213. {    7.0.1, 7.1, and 7 Pro, the compatibility code just doesn't work on        }
  214. {    volumes that don't support PBExchangeFiles (even though you may get a    }
  215. {    noErr result). System Update 3.0 and System 7.5 and later have the        }
  216. {    problems in FSpExchangeFiles corrected.                                    }
  217.  
  218.  
  219. {***************************************************************************}
  220.  
  221.  
  222.     FUNCTION FSpOpenResFileCompat ({CONST}VAR spec: FSSpec;
  223.                                     permission: SignedByte): INTEGER;
  224. {    The FSpOpenResFileCompat function opens the resource file specified        }
  225. {    by spec.                                                                }
  226. {                                                                            }
  227. {    spec            input:    An FSSpec record specifying the file whose        }
  228. {                            resource file is to be opened.                    }
  229. {    permission        input:    A constant indicating the desired file access    }
  230. {                            permissions.                                    }
  231. {    function result    output:    A resource file reference number, or if there's    }
  232. {                            an error -1.                                    }
  233.  
  234.  
  235. {***************************************************************************}
  236.  
  237.  
  238.     PROCEDURE FSpCreateResFileCompat ({CONST}VAR spec: FSSpec;
  239.                                     creator: OSType;
  240.                                     fileType: OSType;
  241.                                     scriptTag: ScriptCode);
  242. {    The FSpCreateResFileCompat function creates a new resource file with    }
  243. {    the specified type, creator, and script code.                            }
  244. {    Differences from FSpCreateResFile: FSpCreateResFileCompat correctly        }
  245. {    sets the fdScript in the file's FXInfo record to scriptTag if the        }
  246. {    problem isn't fixed in the File Manager code.                            }
  247. {                                                                            }
  248. {    spec        input:    An FSSpec record specifying the resource file to    }
  249. {                        create.                                                }
  250. {    creator        input:    The creator of the new file.                        }
  251. {    fileType    input    The file type of the new file.                        }
  252. {    scriptCode    input:    The code of the script system in which the file        }
  253. {                        name is to be displayed.                            }
  254.  
  255.  
  256. {***************************************************************************}
  257.  
  258.  
  259. IMPLEMENTATION
  260.  
  261. END.